
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getUserInfoByToken } from '@/api/user'

export const useUserStore = defineStore('user', () => {
  // 登陆用户的userInfo
  const userInfo = ref(null)
  const getUserInfoAction = async () => {
    return userInfo.value
  }
  const initUserInfoAction = async () => {
    const res = await getUserInfoByToken()
    userInfo.value = res
  }

  return {
    getUserInfoAction, initUserInfoAction,
  }
})